widget: Fix math screwups in clip calculation
authorBenjamin Otte <otte@redhat.com>
Thu, 17 Nov 2016 22:16:14 +0000 (23:16 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 17 Nov 2016 22:16:14 +0000 (23:16 +0100)
We need so subtract the allocation from the clip to get the clip offset,
not the other way around.

This was screwing in particular with marks on GtkScale, because GtkScale
mark clip computation is broken and always returns (0,0) which makes
scales have a waaaaay too large clip.
But that's another bug.

gtk/gtkwidget.c

index 4045e3f501ce2aa4317212aee5bcb21cea280338..c45f9a39ebf23e60aa36e9751588f228c6d7f0d1 100644 (file)
@@ -6413,13 +6413,13 @@ gtk_widget_draw_internal (GtkWidget *widget,
           GskRenderNode *node;
 
           graphene_rect_init (&viewport,
-                              widget->priv->allocation.x - widget->priv->clip.x,
-                              widget->priv->allocation.y - widget->priv->clip.y,
+                              widget->priv->clip.x - widget->priv->allocation.x,
+                              widget->priv->clip.y - widget->priv->allocation.y,
                               widget->priv->clip.width,
                               widget->priv->clip.height);
           clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
-                                                widget->priv->allocation.x - widget->priv->clip.x,
-                                                widget->priv->allocation.y - widget->priv->clip.y,
+                                                widget->priv->clip.x - widget->priv->allocation.x,
+                                                widget->priv->clip.y - widget->priv->allocation.y,
                                                 widget->priv->clip.width,
                                                 widget->priv->clip.height});
           fallback = gsk_renderer_create_fallback (renderer, &viewport, cr);
@@ -15656,7 +15656,7 @@ gtk_widget_snapshot (GtkWidget   *widget,
 
   gtk_widget_get_clip (widget, &clip);
   _gtk_widget_get_allocation (widget, &alloc);
-  graphene_rect_init (&bounds, alloc.x - clip.x, alloc.y - clip.y, clip.width, clip.height);
+  graphene_rect_init (&bounds, clip.x - alloc.x, clip.y - alloc.y, clip.width, clip.height);
   if (gtk_snapshot_clips_rect (snapshot, &bounds))
     return;